package com.yfq.springframework.beans;

import com.yfq.springframework.exception.BeansException;

/**
 * @author 姚凤桥
 * @date 2022/11/13 14:14
 * @description
 */
public abstract class AbstractAutowiredCapableBeanFactory extends AbstractBeanFactory {

    @Override
    protected Object createBean(String beanName, BeanDefinition beanDefinition) {
        Object bean;
        try {
            bean = beanDefinition.getBeanClass().newInstance();
        } catch (InstantiationException | IllegalAccessException e) {
            throw new BeansException(e.getMessage());
        }

        //注册bean
        registerSingleton(beanName, bean);

        return bean;
    }

}
